home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
LOGIC Apps
/
Logic-APPLE_II_APPS.iso
/
mac
/
LOGIC Apple II 5.25" Library - DOS Part 2
/
DOS039.dsk
/
PRIME FACTORS OF INTEGERS.bas
< prev
next >
Wrap
BASIC Source File
|
2012-02-16
|
1KB
|
60 lines
10 ARG$ = "PRIME FACTORS OF INTEGERS": GOSUB 1000
12 ARG$ = "ADAM OSBORNE & ASSOCIATES": GOSUB 3000
20 PRINT
25 GOSUB 2000
30 PRINT "(ENTER 0 TO END PROGRAM)"
35 PRINT
40 PRINT CHR$(7): REM BELL
45 INPUT "ENTER NUMBER:";Z
59 REM - END PROGRAM
60 IF Z = 0 THEN 200
69 REM - THE SIGN OF THE NUMBER IS ALWAYS A FACTOR
70 PRINT SGN(Z)
79 REM - USE ABSOLUTE VALUE FOR CALCULATIONS
80 Z = ABS(Z)
89 REM - LOOP TO TEST ALL INTEGERS (2 THRU Z) AS PRIME FACTORS
90 FOR I = 2 TO Z
100 S = 0
110 IF (Z/I) < > INT(Z/I) THEN 150
120 Z = Z/I
130 S = S +1
140 GOTO 110
149 REM - FIND A PRIME FACTOR? IF YES, PRINT
150 IF S = 0 THEN 170
159 REM - PRINT FACTORS WITH EXPONENTS; I^S = I TO THE S POWER
160 PRINT I;"^";S
170 NEXT I
180 PRINT
189 REM - RESTART PROGRAM
190 GOTO 40
200 END
999 END
1000 REM SCREEN HEADING
1001 REM
1010 HOME
1020 BELL$ = CHR$(7): REM BELL SOUND
1040 PRINT BELL$
1050 HTAB ((40 - LEN(ARG$))/2)
1060 INVERSE
1070 PRINT ARG$
1080 NORMAL
1090 FOR X = 1 TO 38
1100 PRINT "-";
1110 NEXT
1120 PRINT "-"
1990 RETURN
1999 REM
2000 REM DISPLAY COMMENTARY
2001 REM
2010 PRINT "THIS PROGRAM WILL TAKE ANY INTEGER AND CALCULATE ITS PRIME FACTORS. "
2020 PRINT
2990 RETURN
3000 REM SUBHEADING
3001 REM
3050 HTAB ((40 - LEN(ARG$))/2)
3070 PRINT ARG$
3090 FOR X = 1 TO 38
3100 PRINT "-";
3110 NEXT
3120 PRINT "-"
3130 RETURN